home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 3_5.lha / 3_5 / 3_5a2.c < prev    next >
Text File  |  1993-08-08  |  500b  |  23 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / exercise overflow and underflow
  6. include <stream.h>
  7. include <limits.h>
  8.  
  9. nt main(int, char**)
  10.  
  11.    short int i;
  12.    i = SHRT_MAX;
  13.    cout << "SHRT_MAX=" << i << "\n";
  14.    i++;            // overflow
  15.    cout << "SHRT_MAX+1=" << i << "\n";
  16.  
  17.    i = SHRT_MIN;
  18.    cout << "SHRT_MIN=" << i << "\n";
  19.    i--;            // underflow
  20.    cout << "SHRT_MIN-1=" << i << "\n";
  21.    return 0;
  22.  
  23.